package com.cg.design.graphicdesignpattern.interpreter.language;

/**
 * 对应<program>标签的类，继承了BaseNode类
 *
 * @program: LeetCode->ProgramNode
 * @author: cg
 * @create: 2022-04-06 08:37
 **/
public class ProgramNode extends BaseNode {

    /**
     * 用于保存<command list>对应的节点
     */
    private BaseNode commandListNode;

    @Override
    public void parse(Context context) throws ParseException {
        context.skipToken("program");
        commandListNode = new CommandListNode();
        commandListNode.parse(context);
    }

    @Override
    public void execute() throws ExecuteException {
        commandListNode.execute();
    }

    @Override
    public String toString() {
        return "[" + "program " + commandListNode + ']';
    }
}
